programming4us
           
 
 
SQL Server

Migrating Databases and Data to SQL Azure (part 6) - Building a Migration Package

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/29/2010 9:58:23 AM
2.2. Clearing Any Preexisting Data

Let's clear any data that exists in the SQL Azure database so you can start with a clean slate. In SSMS, open a new query connecting to the TechBio database, and delete the data from the UserDocs, Users, and Docs tables by executing the following DELETE statements:

DELETE FROM UserDocs
DELETE FROM Docs
DELETE FROM Users

All three of those tables should now contain no data, as shown in Figure 8.

Figure 8. Checking for existing data

2.3. Building a Migration Package

Let's start building an SSIS package to migrate your data. Follow these steps:

  1. In the SSIS package designer, select the Control Flow tab, and drag an Execute SQL task and three data flow tasks from the Toolbox onto the Control Flow designer.

  2. Right-click Execute SQL task, and select Edit from the context menu. The Execute SQL Task Editor opens.

  3. Change the task name to Clear Data, leave the Connection Type as OLE DB, and leave the SQLSourceType as Direct Input.

  4. In the Connection property, select <New connection>, as shown in Figure 9. The Connection Manager dialog opens (see Figure 10).

    Figure 9. Adding a new connection
    Figure 10. Entering the connection information
  5. In the Connection Manager dialog, enter the server name of your SQL Azure server, select Use SQL Authentication, and enter your SQL Azure username and password. The username must be in the format username@server where username is your Administrator username or a valid SQL Azure username and server is the first part of the server name (the piece prior to .database.windows.net).

  6. In the "Select or enter a database name" field, the OLE DB provider doesn't return a list of databases. No big deal: type in the name TechBio.

  7. Click the Test Connection button. If you've entered everything correctly and your firewall is set up, your test connection succeeds.

  8. Click OK in the Connection Manager dialog.

  9. Back in the Execute SQL Task Editor, click the ellipsis button in the SQLStatement property to display a small Enter SQL Query dialog in which to enter one or more T-SQL statements. Enter the following DELETE statements, which clear out the data from the previous example. (This isn't critical, but it gives you a clean slate to start with.)

    DELETE FROM UserDocs
    DELETE FROM Users
    DELETE FROM Docs

  10. Click OK in the Enter SQL Query dialog. The Execute SQL Task Editor dialog should look like Figure 11. Click OK.

    Figure 11. Execute SQL Task Editor
  11. Back on the Control Flow tab in the SSIS package designer, make sure the Clear Data task is highlighted. Notice the green arrow coming from the bottom of the Clear Data task: click anywhere on this green arrow, and drag it to the first data flow task. Doing so creates a connection from the Clear Data task to the first data flow task, signifying the flow of execution. You can see an example of this in Figure 5-14.When the Clear Data task has completed executing, the first data flow task will then execute.

  12. Let's add logic to the first data flow task. Double-click the linked data flow task (or right-click and select Edit). Doing so takes you to the Data Flow tab.

  13. Drag an OLE DB Source task and an OLE DB Destination task to the Data Flow designer surface. This is where the actions of pulling data from the source database (the local DB) and copying it to the destination database (SQL Azure) take place.

  14. Right-click the OLE DB Source task, and click Edit. Doing so opens the OLE DB Source Editor, where you define a connection to your local database, such as the connection shown in Figure 5-10. You already have a connection to the SQL Azure database, but you need to create a connection to your local database that your tasks use to copy the data.

  15. On the OLE DB Source Editor task, you see the connection to the SQL Azure database. Click the New button to open the Configure OLE DB Connection Manager dialog. Click New again to open the Connection Manager dialog you saw in Figure 10.

  16. In this dialog, enter the information to connect to your local copy of the TechBio database.

  17. Test the connection, and then click OK in the Connection Manager dialog.

  18. Click OK in the Configure OLE DB Connection Manager dialog.

  19. Back in the OLE DB Source Editor, click the Table/View drop-down, select the Docs table, and then click OK.

  20. As you did for the control flow task, drag the green arrow from the OLE DB Source task to the OLE DB Destination task.

  21. Double-click the OLE DB Source task to edit the task properties, which is where the data is going: the SQL Azure database. Because you've already created a connection to the SQL Azure database, you can use that connection. In the OLE DB Destination Editor, select the SQL Azure connection, and then select the Docs table from the drop-down list of tables. Oops—you get the error shown in Figure 12.

    Figure 12. OLE DB connection error

This is interesting, because you didn't get this error when configuring the Execute SQL task. The difference is that the two Connection Manager dialogs don't operate quite the same way. The Connection Manager dialog for the Execute SQL task let you type in the table name, whereas the Connection Manager dialog for the OLE DB Destination task required you to select from the list. But when you expanded the list, you received the error shown in Figure 12.

The fix is to use an ADO.NET destination instead of the OLE DB destination. To do this, continue as follows:

  1. Delete the OLE DB Destination task, and drag an ADO.NET Destination task onto the surface.

  2. Connect to the two tasks, and then double-click the ADO.NET Destination task to configure it.

  3. In the ADO.NET Destination Editor dialog, click the New button to configure a new ADO.NET connection.

  4. Walk through the same steps as in the previous two connection configurations. This time, you're able to type the database name in the Connection Manager dialog.

  5. Click OK in the all the dialogs until you're back to the ADO.NET Destination Editor.

  6. Before you click OK in this dialog, click Mappings at left, as shown in Figure 13. Doing so ensures that the source table columns are appropriately mapped to the destination table columns. Click OK in the ADO.NET Destination Editor

If you're new to SSIS, congratulations: you've just configured your first SSIS data flow. Your data flow should look like Figure 14—not very exciting, but useful nonetheless. If you aren't new to SSIS, you still deserve congratulations, because you've successfully configured a data flow to migrate data to the cloud.

Figure 13. ADO.NET Destination Editor with mappings

Figure 14. Data flow

Put down the root beer, though, because you aren't quite done. Continue with these steps:

  1. Go back to the Control Flow tab, and connect the first data flow task to the second data flow task, and connect the second and third data flow tasks.

  2. Double-click the second data flow task, and do the same thing you did for the first data flow beginning in step 12. You don't need to re-create the connections, but in the Source and Destination Editors for the second data flow, select the Users table.

  3. Repeat the process for the third data flow task, this time selecting the UserDocs table.

When you're finished, your control flow task should look like Figure 15. The tasks aren't green (yet), but the flow should be similar.

Figure 15. Successful execution of an SSIS package
Other -----------------
- Understanding Service Broker Constructs (part 3)
- Understanding Service Broker Constructs (part 2) - Creating Queues for Message Storage
- Understanding Service Broker Constructs (part 1) - Defining Messages and Choosing a Message Type
- SQL Server 2008 : SQL Server Service Broker - Designing a Sample System
- SQL Server 2008 : SQL Server Service Broker - Understanding Distributed Messaging
- SQL Server 2008 : Full-Text Search Troubleshooting
- SQL Azure : Security - Access Control
- SQL Server 2008 : Full-Text Searches (part 3) - Stop Lists
- SQL Server 2008 : Full-Text Searches (part 2)
- SQL Server 2008 : Full-Text Searches (part 1) - Search Phrase
- SQL Azure : Securing Your Data (part 3) - Certificates
- SQL Azure : Securing Your Data (part 2) - Hashing
- SQL Azure : Securing Your Data (part 1) - Encryption
- SQL Azure : Security - Overview
- Setting Up a Full-Text Index (part 4) - Using the Full-Text Indexing Wizard to Build Full-Text Indexes and Catalogs
- Setting Up a Full-Text Index (part 3) - Diagnostics
- Setting Up a Full-Text Index (part 2) - Full-Text Indexing of BLOBs and XML
- Setting Up a Full-Text Index (part 1) - Using T-SQL Commands to Build Full-Text Indexes and Catalogs
- Implementing SQL Server 2008 Full-Text Catalogs
- How SQL Server FTS Works
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us